<ul class="nav user-bar navbar-nav navbar-right">
  <% if current_user %>
  <li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><%= current_user.login %> <span class="caret"></span></a>
    <button class="navbar-toggle" type="button" data-toggle="dropdown" role="button" aria-expanded="false">
      <span class="sr-only">Toggle</span>
      <i class="fa fa-reorder"></i>
    </button>
    <%= render_list class: "dropdown-menu", role: "menu" do |li|
      li << link_to(t("menu.my_home_page"), user_path(current_user) )
      li << "<div class='divider'></div>"
      li << link_to(t("menu.edit_account_path"), edit_user_registration_path)
      li << link_to(t("menu.notes"), notes_path )
      li << link_to(t("menu.likes"), favorites_user_path(current_user))
      if admin?
        li << "<div class='divider'></div>"
        if params[:controller].start_with?("admin")
          li << link_to("回到前台", main_app.root_path)
        else
          li << link_to(t("menu.admin"), "/admin")
        end
      end
      li << "<div class='divider'></div>"
      li << link_to(t("common.logout"), destroy_user_session_path, method: "delete" )
    end %>
  </li>
  <% else %>
  <li><%= link_to( t("common.register"), new_user_registration_path) %></li>
  <li><%= link_to( t("common.login"), new_user_session_path ) %></li>
  <% end %>
</ul>
